﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class ePioneer_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetQuestionList();
            GetRealList();
        }
    }

    /// <summary>
    /// 最高战法
    /// </summary>
    public void GetRealList()
    {
        string cmsService = System.Configuration.ConfigurationManager.ConnectionStrings["CMSService"].ToString();
        StringBuilder sbReturn = new StringBuilder();
        cmsService += "ep_real.ashx?action=GetAllRealList";
        List<ePioneer_Real> listf = UrlGet.GetObject<List<ePioneer_Real>>(cmsService);
        //最高战法
        listf = listf.OrderByDescending(p => p.Average).Take(4).ToList();
        foreach (var n in listf)
        {
            //平均分
            var Average = n.Average; //(from s in dal.ePioneer_RealComment
            //评论条数
            int iRCcount = int.Parse(n.Count);//dal.ePioneer_RealComment.Where(x => (x.rid == n.id)).Count();
            sbReturn.Append("<div class='dp_mini_index_foot1_tiao pd7'><div class='dp_mini_index_foot1_zi fl'><a href='ep_real.aspx?id=" + n.ID + "'>" + n.Name + "</a></div><div class='dp_mini_index_foot1_xin" + Math.Round(Convert.ToDecimal(Average)) + " fl'></div><div class='dp_mini_index_foot1_pin fl'><a href='ep_comment.aspx?realId=" + n.ID + "'>" + iRCcount + "条评论</a></div><div class='clr'></div></div>");
        }
        realList.InnerHtml = sbReturn.ToString();
    }

    /// <summary>
    /// 获取常见问题
    /// </summary>
    /// <returns></returns>
    public void GetQuestionList()
    {
        StringBuilder sbReturn = new StringBuilder();
        string cmsService = System.Configuration.ConfigurationManager.ConnectionStrings["CMSService"].ToString();
        cmsService += "ep_question.ashx?action=GetQuestionList";
        var qlist = UrlGet.GetObject<List<ePioneer_Question>>(cmsService).OrderByDescending(p => p.Count).Take(3);
        foreach (var n in qlist)
        {
            sbReturn.AppendLine("<div class='black' title='" + n.Title.ToString() + "'>" + n.Count + " <a href='javascript:void(0)' onclick='AddCount(" + n.ID + ")'>" + n.Title.ToString() + "</a></div>");
        }
        questionList.InnerHtml = sbReturn.ToString();
    }
}